package com.csi.service.impl;

import com.csi.dao.impl.RoomDaoImpl;
import com.csi.dao.RoomDao;
import com.csi.domain.Room;
import com.csi.service.RoomService;

import java.sql.SQLException;
import java.util.List;

public class RoomServiceImpl implements RoomService {
    @Override
    public List<Room> findAll(int typeId) {
        RoomDao roomDao=new RoomDaoImpl();
        List<Room> all = null;
        try {
            all = roomDao.findAll(typeId);
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }
        return all;
    }

    @Override
    public int add(Room room) {
        RoomDao roomDao=new RoomDaoImpl();
        int add = 0;
        try {
            add = roomDao.add(room);
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }

        return add;
    }

    @Override
    public int delete(int ROOM) {

        RoomDao roomDao=new RoomDaoImpl();

        int delete = 0;
        try {
            delete = roomDao.delete(ROOM);
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }

        return delete;
    }

    @Override
    public int update(Room room) {

        RoomDao roomDao=new RoomDaoImpl();

        int update = 0;
        try {
            update = roomDao.update(room);
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }
        return update;
    }
}
